package com.bruce.asurada.sso.client.config;

import com.bruce.asurada.sso.client.interceptor.SsoInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置类
 * 
 * @author Bruce
 */
@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {

    private final SsoInterceptor ssoInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(ssoInterceptor)
                .addPathPatterns("/**")  // 拦截所有路径
                .excludePathPatterns(
                    "/",                    // 首页
                    "/login",               // 登录页面
                    "/sso/login",           // SSO登录接口
                    "/sso/callback",        // SSO回调接口
                    "/sso/check",           // 登录状态检查
                    "/actuator/**",         // 健康检查端点
                    "/favicon.ico",         // 网站图标
                    "/css/**",              // CSS静态资源
                    "/js/**",               // JavaScript静态资源
                    "/images/**",           // 图片静态资源
                    "/static/**",           // 其他静态资源
                    "/error"                // 错误页面
                );
    }
}